/*==============================================================*/
/* DBMS name:      Microsoft SQL Server 2000                    */
/* Created on:     2009-10-11 16:07:26                          */
/*==============================================================*/


ALTER TABLE BIZ_GOAL_DETAIL
   DROP CONSTRAINT FK_BIZ_GOAL_REFERENCE_BIZ_GOAL
go

ALTER TABLE BIZ_ORG_CHECK
   DROP CONSTRAINT FK_BIZ_ORG__REFERENCE_BIZ_GOAL
go

ALTER TABLE BIZ_ORG_CHECK
   DROP CONSTRAINT FK_BIZ_ORG__REFERENCE_BIZ_GOAL
go

ALTER TABLE BIZ_ORG_DEMOCRACY
   DROP CONSTRAINT FK_BIZ_ORG__REFERENCE_BIZ_DEMO
go

ALTER TABLE BIZ_ORG_DEMOCRACY
   DROP CONSTRAINT FK_BIZ_ORG__REFERENCE_BIZ_DEMO
go

ALTER TABLE BIZ_ORG_DEMOCRACY
   DROP CONSTRAINT FK_BIZ_ORG__REFERENCE_BIZ_DEMO
go

ALTER TABLE BIZ_ORG_GOAL_SETTING
   DROP CONSTRAINT FK_BIZ_ORG__REFERENCE_SYS_ORG
go

ALTER TABLE BIZ_ORG_GOAL_SETTING
   DROP CONSTRAINT FK_BIZ_ORG__REFERENCE_BIZ_GOAL
go

ALTER TABLE SYS_ROLE_PERMISSION
   DROP CONSTRAINT FK_SYS_ROLE_REFERENCE_SYS_PERM
go

ALTER TABLE SYS_ROLE_PERMISSION
   DROP CONSTRAINT FK_SYS_ROLE_REFERENCE_SYS_ROLE
go

ALTER TABLE SYS_USER
   DROP CONSTRAINT FK_SYS_USER_REFERENCE_SYS_ORG
go

ALTER TABLE SYS_USER_ROLE
   DROP CONSTRAINT FK_SYS_USER_REFERENCE_SYS_ROLE
go

ALTER TABLE SYS_USER_ROLE
   DROP CONSTRAINT FK_SYS_USER_REFERENCE_SYS_USER
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('BIZ_CMS')
            AND   TYPE = 'U')
   DROP TABLE BIZ_CMS
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('BIZ_DEMOCRACY_CHECKMAN')
            AND   TYPE = 'U')
   DROP TABLE BIZ_DEMOCRACY_CHECKMAN
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('BIZ_DEMOCRACY_GOAL')
            AND   TYPE = 'U')
   DROP TABLE BIZ_DEMOCRACY_GOAL
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('BIZ_DEMOCRACY_SCORE')
            AND   TYPE = 'U')
   DROP TABLE BIZ_DEMOCRACY_SCORE
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('BIZ_GOAL_CATEGORY')
            AND   TYPE = 'U')
   DROP TABLE BIZ_GOAL_CATEGORY
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('BIZ_GOAL_DETAIL')
            AND   TYPE = 'U')
   DROP TABLE BIZ_GOAL_DETAIL
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('BIZ_GOAL_SELF')
            AND   TYPE = 'U')
   DROP TABLE BIZ_GOAL_SELF
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('BIZ_MESSAGE')
            AND   TYPE = 'U')
   DROP TABLE BIZ_MESSAGE
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('BIZ_ORG_CHECK')
            AND   TYPE = 'U')
   DROP TABLE BIZ_ORG_CHECK
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('BIZ_ORG_DEMOCRACY')
            AND   TYPE = 'U')
   DROP TABLE BIZ_ORG_DEMOCRACY
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('BIZ_ORG_DEMOCRACY_SUM')
            AND   TYPE = 'U')
   DROP TABLE BIZ_ORG_DEMOCRACY_SUM
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('BIZ_ORG_GOAL_SETTING')
            AND   TYPE = 'U')
   DROP TABLE BIZ_ORG_GOAL_SETTING
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('SYS_ORG')
            AND   TYPE = 'U')
   DROP TABLE SYS_ORG
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('SYS_PERMISSION')
            AND   TYPE = 'U')
   DROP TABLE SYS_PERMISSION
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('SYS_RESOURCE')
            AND   TYPE = 'U')
   DROP TABLE SYS_RESOURCE
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('SYS_ROLE')
            AND   TYPE = 'U')
   DROP TABLE SYS_ROLE
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('SYS_ROLE_PERMISSION')
            AND   TYPE = 'U')
   DROP TABLE SYS_ROLE_PERMISSION
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('SYS_USER')
            AND   TYPE = 'U')
   DROP TABLE SYS_USER
go

IF EXISTS (SELECT 1
            FROM  SYSOBJECTS
           WHERE  ID = OBJECT_ID('SYS_USER_ROLE')
            AND   TYPE = 'U')
   DROP TABLE SYS_USER_ROLE
go

/*==============================================================*/
/* Table: BIZ_CMS                                               */
/*==============================================================*/
CREATE TABLE BIZ_CMS (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   ORG_ID               int                  null,
   TYPE                 varchar(32)          null,
   TITLE                varchar(1024)        null,
   CONTENT              text                 null,
   ATTACHMENT_PATH      varchar(1024)        null,
   MEMO                 varchar(1024)        null,
   constraint PK_BIZ_CMS primary key (ID)
)
go

DECLARE @CMTBIZ_CMS VARCHAR(128)
SELECT @CMTBIZ_CMS = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '信息发布内容表',
   'user', @CMTBIZ_CMS, 'table', 'BIZ_CMS'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'BIZ_CMS', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '发布信息的组织id',
   'user', '', 'table', 'BIZ_CMS', 'column', 'ORG_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'notice：通知公告 method：考核办法 ',
   'user', '', 'table', 'BIZ_CMS', 'column', 'TYPE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '信息标题',
   'user', '', 'table', 'BIZ_CMS', 'column', 'TITLE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '信息内容',
   'user', '', 'table', 'BIZ_CMS', 'column', 'CONTENT'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '附件路径，视具体情况使用，如果用在线编辑器（fckeditor）则可以不用',
   'user', '', 'table', 'BIZ_CMS', 'column', 'ATTACHMENT_PATH'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注',
   'user', '', 'table', 'BIZ_CMS', 'column', 'MEMO'
go

/*==============================================================*/
/* Table: BIZ_DEMOCRACY_CHECKMAN                                */
/*==============================================================*/
CREATE TABLE BIZ_DEMOCRACY_CHECKMAN (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   NAME                 varchar(1024)        null,
   ORDERING             int                  null,
   WEIGHT               float                null,
   YEAR                 int                  null,
   constraint PK_BIZ_DEMOCRACY_CHECKMAN primary key (ID)
)
go

DECLARE @CMTBIZ_DEMOCRACY_CHECKMAN VARCHAR(128)
SELECT @CMTBIZ_DEMOCRACY_CHECKMAN = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '民主评议指标考核责任人库（
   1.市级五套班子领导干部及在职副县（市）级以上领导干部，2.市级机关和开发区职能部门领导班子成员，3.镇（街道）党政领导班子及成员，4.市级机关、开发区职能部门中层干部代表、镇（街道）中层干部代表以及村、社区（居委）党组织书记和村（社区）干部代表，5.副县（市）级以上老干部、市及市级以上党代表、人大代表、政协委员、企业代表、城乡居民（村民）代表以及新闻工作者代表）',
   'user', @CMTBIZ_DEMOCRACY_CHECKMAN, 'table', 'BIZ_DEMOCRACY_CHECKMAN'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'BIZ_DEMOCRACY_CHECKMAN', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '名称',
   'user', '', 'table', 'BIZ_DEMOCRACY_CHECKMAN', 'column', 'NAME'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序，预留
   ',
   'user', '', 'table', 'BIZ_DEMOCRACY_CHECKMAN', 'column', 'ORDERING'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '评分系数,即不同的评分评议责任人类型，给出同样的评议结果，但分值不同：
   例如：
   对于评议指标： 党风建设    A=5分 B＝4分
    评议责任人           党风建设        得分
   市级五套班子            A                   A*1.2=6 分
   老干部                        A                   A*1.0=5 分',
   'user', '', 'table', 'BIZ_DEMOCRACY_CHECKMAN', 'column', 'WEIGHT'
go

/*==============================================================*/
/* Table: BIZ_DEMOCRACY_GOAL                                    */
/*==============================================================*/
CREATE TABLE BIZ_DEMOCRACY_GOAL (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   CONTENT              varchar(4000)        null,
   POINT                float                null,
   SPEC                 varchar(4000)        null,
   ORDERING             int                  null,
   YEAR                 int                  null,
   constraint PK_BIZ_DEMOCRACY_GOAL primary key (ID)
)
go

DECLARE @CMTBIZ_DEMOCRACY_GOAL VARCHAR(128)
SELECT @CMTBIZ_DEMOCRACY_GOAL = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '民主评议指标库',
   'user', @CMTBIZ_DEMOCRACY_GOAL, 'table', 'BIZ_DEMOCRACY_GOAL'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'BIZ_DEMOCRACY_GOAL', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指标内容',
   'user', '', 'table', 'BIZ_DEMOCRACY_GOAL', 'column', 'CONTENT'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指标说明',
   'user', '', 'table', 'BIZ_DEMOCRACY_GOAL', 'column', 'SPEC'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序
   ',
   'user', '', 'table', 'BIZ_DEMOCRACY_GOAL', 'column', 'ORDERING'
go

/*==============================================================*/
/* Table: BIZ_DEMOCRACY_SCORE                                   */
/*==============================================================*/
CREATE TABLE BIZ_DEMOCRACY_SCORE (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   SYMBOL               varchar(10)          null,
   REMARK               varchar(1000)        null,
   POINT                float                null,
   ORDERING             int                  null,
   YEAR                 int                  null,
   constraint PK_BIZ_DEMOCRACY_SCORE primary key (ID)
)
go

DECLARE @CMTBIZ_DEMOCRACY_SCORE VARCHAR(128)
SELECT @CMTBIZ_DEMOCRACY_SCORE = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '民主评议指标评分类型表',
   'user', @CMTBIZ_DEMOCRACY_SCORE, 'table', 'BIZ_DEMOCRACY_SCORE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'BIZ_DEMOCRACY_SCORE', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'A,B,C,D,E等评分等级符号，不同符号代表不同分值',
   'user', '', 'table', 'BIZ_DEMOCRACY_SCORE', 'column', 'SYMBOL'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指标说明',
   'user', '', 'table', 'BIZ_DEMOCRACY_SCORE', 'column', 'REMARK'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '评分符号代表的分值',
   'user', '', 'table', 'BIZ_DEMOCRACY_SCORE', 'column', 'POINT'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序，预留
   ',
   'user', '', 'table', 'BIZ_DEMOCRACY_SCORE', 'column', 'ORDERING'
go

/*==============================================================*/
/* Table: BIZ_GOAL_CATEGORY                                     */
/*==============================================================*/
CREATE TABLE BIZ_GOAL_CATEGORY (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   NAME                 varchar(128)         null,
   POINT                float                null,
   PARENT_ID            int                  null,
   ORDERING             int                  null,
   "PERCENT"            float                null,
   VALUE                varchar(2048)        null,
   IS_FIXED             char(1)              null,
   TAG                  varchar(2048)        null,
   CHECK_ORG_ID         int                  null,
   YEAR                 int                  null,
   CATEGORY_ID_PATH     varchar(1024)        null,
   CATEGORY_NAME_PATH   varchar(2048)        null,
   IS_LEAF              char(1)              null,
   LEVEL                int                  null,
   STATUS               varchar(32)          null,
   constraint PK_BIZ_GOAL_CATEGORY primary key (ID)
)
go

DECLARE @CMTBIZ_GOAL_CATEGORY VARCHAR(128)
SELECT @CMTBIZ_GOAL_CATEGORY = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指标类别目录',
   'user', @CMTBIZ_GOAL_CATEGORY, 'table', 'BIZ_GOAL_CATEGORY'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'BIZ_GOAL_CATEGORY', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指标目录项（节点）名称',
   'user', '', 'table', 'BIZ_GOAL_CATEGORY', 'column', 'NAME'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指标目录项的分值',
   'user', '', 'table', 'BIZ_GOAL_CATEGORY', 'column', 'POINT'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '父节点id',
   'user', '', 'table', 'BIZ_GOAL_CATEGORY', 'column', 'PARENT_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序',
   'user', '', 'table', 'BIZ_GOAL_CATEGORY', 'column', 'ORDERING'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指标目录和指标细则换算关系（％）
   ',
   'user', '', 'table', 'BIZ_GOAL_CATEGORY', 'column', 'PERCENT'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '目录项值（预留）',
   'user', '', 'table', 'BIZ_GOAL_CATEGORY', 'column', 'VALUE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '目录项值（预留）',
   'user', '', 'table', 'BIZ_GOAL_CATEGORY', 'column', 'IS_FIXED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '预留（考虑，给指标目录分类等）',
   'user', '', 'table', 'BIZ_GOAL_CATEGORY', 'column', 'TAG'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指标目录的考核责任单位',
   'user', '', 'table', 'BIZ_GOAL_CATEGORY', 'column', 'CHECK_ORG_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '这里目录id路径质保存到上级即可，目录id之间用“/”分割，如 100/1001/200',
   'user', '', 'table', 'BIZ_GOAL_CATEGORY', 'column', 'CATEGORY_ID_PATH'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '目录项名称路径：如：公共指标/基础工作/廉政建设',
   'user', '', 'table', 'BIZ_GOAL_CATEGORY', 'column', 'CATEGORY_NAME_PATH'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'y:是叶子节点，n：不是叶子节点。',
   'user', '', 'table', 'BIZ_GOAL_CATEGORY', 'column', 'IS_LEAF'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '节点坐在树的层次',
   'user', '', 'table', 'BIZ_GOAL_CATEGORY', 'column', 'LEVEL'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '目录状态',
   'user', '', 'table', 'BIZ_GOAL_CATEGORY', 'column', 'STATUS'
go

/*==============================================================*/
/* Table: BIZ_GOAL_DETAIL                                       */
/*==============================================================*/
CREATE TABLE BIZ_GOAL_DETAIL (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   CATEGORY_ID          int                  null,
   CONTENT              varchar(4000)        null,
   POINT                float                null,
   SPEC                 varchar(4000)        null,
   ORDERING             int                  null,
   MEMO                 varchar(2048)        null,
   CHECK_ORG_ID         int                  null,
   "PERCENT"            float                null,
   CATEGORY_ID_PATH     varchar(1024)        null,
   CATEGORY_NAME_PATH   varchar(2048)        null,
   YEAR                 int                  null,
   constraint PK_BIZ_GOAL_DETAIL primary key (ID)
)
go

DECLARE @CMTBIZ_GOAL_DETAIL VARCHAR(128)
SELECT @CMTBIZ_GOAL_DETAIL = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指标细则库',
   'user', @CMTBIZ_GOAL_DETAIL, 'table', 'BIZ_GOAL_DETAIL'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'BIZ_GOAL_DETAIL', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指标目录id',
   'user', '', 'table', 'BIZ_GOAL_DETAIL', 'column', 'CATEGORY_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指标考核内容',
   'user', '', 'table', 'BIZ_GOAL_DETAIL', 'column', 'CONTENT'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '该指标的标准分值',
   'user', '', 'table', 'BIZ_GOAL_DETAIL', 'column', 'POINT'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '该指标的评分标准',
   'user', '', 'table', 'BIZ_GOAL_DETAIL', 'column', 'SPEC'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序，预留
   ',
   'user', '', 'table', 'BIZ_GOAL_DETAIL', 'column', 'ORDERING'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注，预留',
   'user', '', 'table', 'BIZ_GOAL_DETAIL', 'column', 'MEMO'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '考核责任单位',
   'user', '', 'table', 'BIZ_GOAL_DETAIL', 'column', 'CHECK_ORG_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指标目录和指标细则换算关系（％）
   ',
   'user', '', 'table', 'BIZ_GOAL_DETAIL', 'column', 'PERCENT'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指标目录id 路径',
   'user', '', 'table', 'BIZ_GOAL_DETAIL', 'column', 'CATEGORY_ID_PATH'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '考核指标目录名称路径',
   'user', '', 'table', 'BIZ_GOAL_DETAIL', 'column', 'CATEGORY_NAME_PATH'
go

/*==============================================================*/
/* Table: BIZ_GOAL_SELF                                         */
/*==============================================================*/
CREATE TABLE BIZ_GOAL_SELF (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   ORGID                int                  null,
   CONTENT              varchar(4000)        null,
   POINT                float                null,
   SPEC                 varchar(4000)        null,
   ORDERING             int                  null,
   MEMO                 varchar(2048)        null,
   CHECK_ORG_ID         int                  null,
   YEAR                 int                  null,
   AUDIT_MAN_ID         int                  null,
   AUDIT_ORG_ID         int                  null,
   AUDIT_RESULT         varchar(32)          null,
   AUDIT_CONTENT        varchar(4000)        null,
   TYPE                 varchar(32)          null,
   constraint PK_BIZ_GOAL_SELF primary key (ID)
)
go

DECLARE @CMTBIZ_GOAL_SELF VARCHAR(128)
SELECT @CMTBIZ_GOAL_SELF = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '自荐指标及申请加减分指标表',
   'user', @CMTBIZ_GOAL_SELF, 'table', 'BIZ_GOAL_SELF'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'BIZ_GOAL_SELF', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '申报自荐指标的部门id',
   'user', '', 'table', 'BIZ_GOAL_SELF', 'column', 'ORGID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '自荐指标内容',
   'user', '', 'table', 'BIZ_GOAL_SELF', 'column', 'CONTENT'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指标的分值',
   'user', '', 'table', 'BIZ_GOAL_SELF', 'column', 'POINT'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '评分标准',
   'user', '', 'table', 'BIZ_GOAL_SELF', 'column', 'SPEC'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序，预留可不用
   ',
   'user', '', 'table', 'BIZ_GOAL_SELF', 'column', 'ORDERING'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注内容，预留可不用',
   'user', '', 'table', 'BIZ_GOAL_SELF', 'column', 'MEMO'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '考核该指标的部门单位。自荐单位在自荐时指定',
   'user', '', 'table', 'BIZ_GOAL_SELF', 'column', 'CHECK_ORG_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '考核年度',
   'user', '', 'table', 'BIZ_GOAL_SELF', 'column', 'YEAR'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '审核人id，该字段预留，暂可以不填写',
   'user', '', 'table', 'BIZ_GOAL_SELF', 'column', 'AUDIT_MAN_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '审核部门（审核该指标是否作为年度绩效指标），该字段为预留。可暂不用
   如果考核单位和审核单位不同，则可用该字段',
   'user', '', 'table', 'BIZ_GOAL_SELF', 'column', 'AUDIT_ORG_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'yes:审核通过 no：审核不通过',
   'user', '', 'table', 'BIZ_GOAL_SELF', 'column', 'AUDIT_RESULT'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '审核意见',
   'user', '', 'table', 'BIZ_GOAL_SELF', 'column', 'AUDIT_CONTENT'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '自荐指标类型：normal 自荐常规指标   add：自荐加减分指标',
   'user', '', 'table', 'BIZ_GOAL_SELF', 'column', 'TYPE'
go

/*==============================================================*/
/* Table: BIZ_MESSAGE                                           */
/*==============================================================*/
CREATE TABLE BIZ_MESSAGE (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   SEND_MAN_ID          int                  null,
   SEND_ORG_ID          int                  null,
   REPLY_MAN_ID         int                  null,
   REPLY_ORG_ID         int                  null,
   TITLE                varchar(1024)        null,
   CONTENT              varchar(4000)        null,
   PARENT_ID            int                  null,
   MSG_TYPE             varchar(32)          null,
   STATUS               varchar(32)          null,
   constraint PK_BIZ_MESSAGE primary key (ID)
)
go

DECLARE @CMTBIZ_MESSAGE VARCHAR(128)
SELECT @CMTBIZ_MESSAGE = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '消息表，考核责任部门和考核部门之间的通信。包括：批示，督办，通知等。',
   'user', @CMTBIZ_MESSAGE, 'table', 'BIZ_MESSAGE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'BIZ_MESSAGE', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '督查通知单',
   'user', '', 'table', 'BIZ_MESSAGE', 'column', 'TITLE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '反馈意见',
   'user', '', 'table', 'BIZ_MESSAGE', 'column', 'PARENT_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '消息类型：
   approve：批示，notic：通知，urge：督办',
   'user', '', 'table', 'BIZ_MESSAGE', 'column', 'MSG_TYPE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '状态：
   new：新，read：已读',
   'user', '', 'table', 'BIZ_MESSAGE', 'column', 'STATUS'
go

/*==============================================================*/
/* Table: BIZ_ORG_CHECK                                         */
/*==============================================================*/
CREATE TABLE BIZ_ORG_CHECK (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   DETAIL_ID            int                  null,
   ORG_ID               int                  null,
   GO_STATUS            varchar(128)         null,
   FINISH_RESULT        varchar(4000)        null,
   SCORE                float                null,
   SELF_SCORE           float                null,
   MEMO                 varchar(2048)        null,
   CHECK_ORG_ID         int                  null,
   CHECK_RESULT         varchar(2048)        null,
   YEAR                 int                  null,
   TYPE                 varchar(32)          null,
   CHECK_STATUS         varchar(32)          null,
   constraint PK_BIZ_ORG_CHECK primary key (ID)
)
go

DECLARE @CMTBIZ_ORG_CHECK VARCHAR(128)
SELECT @CMTBIZ_ORG_CHECK = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '部门考核表',
   'user', @CMTBIZ_ORG_CHECK, 'table', 'BIZ_ORG_CHECK'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'BIZ_ORG_CHECK', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指标细则id',
   'user', '', 'table', 'BIZ_ORG_CHECK', 'column', 'DETAIL_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '被考核部门组织id',
   'user', '', 'table', 'BIZ_ORG_CHECK', 'column', 'ORG_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '该考核指标的进展状态',
   'user', '', 'table', 'BIZ_ORG_CHECK', 'column', 'GO_STATUS'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '该考核指标的完成情况',
   'user', '', 'table', 'BIZ_ORG_CHECK', 'column', 'FINISH_RESULT'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '考核得分（考核责任单位的打分）',
   'user', '', 'table', 'BIZ_ORG_CHECK', 'column', 'SCORE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '自评分',
   'user', '', 'table', 'BIZ_ORG_CHECK', 'column', 'SELF_SCORE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注，预留',
   'user', '', 'table', 'BIZ_ORG_CHECK', 'column', 'MEMO'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '考核责任单位id',
   'user', '', 'table', 'BIZ_ORG_CHECK', 'column', 'CHECK_ORG_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '审核意见',
   'user', '', 'table', 'BIZ_ORG_CHECK', 'column', 'CHECK_RESULT'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '考核年度',
   'user', '', 'table', 'BIZ_ORG_CHECK', 'column', 'YEAR'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '指标类型：self 自荐指标 normal：正常考核指标',
   'user', '', 'table', 'BIZ_ORG_CHECK', 'column', 'TYPE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '考核状态：
   new：新建，self：自已已填报　check: 已考核',
   'user', '', 'table', 'BIZ_ORG_CHECK', 'column', 'CHECK_STATUS'
go

/*==============================================================*/
/* Table: BIZ_ORG_DEMOCRACY                                     */
/*==============================================================*/
CREATE TABLE BIZ_ORG_DEMOCRACY (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   GOAL_ID              int                  null,
   ORG_ID               int                  null,
   SCORE                float                null,
   MEMO                 varchar(2048)        null,
   CHECK_ORG_ID         int                  null,
   YEAR                 int                  null,
   CHECKMAN_ID          int                  null,
   SCORE_ID             int                  null,
   constraint PK_BIZ_ORG_DEMOCRACY primary key (ID)
)
go

DECLARE @CMTBIZ_ORG_DEMOCRACY VARCHAR(128)
SELECT @CMTBIZ_ORG_DEMOCRACY = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '民主评议指标考评结果
   对于考核结果其它统计，可以考虑基于本表建立视图实现。',
   'user', @CMTBIZ_ORG_DEMOCRACY, 'table', 'BIZ_ORG_DEMOCRACY'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'BIZ_ORG_DEMOCRACY', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '民主评议指标id',
   'user', '', 'table', 'BIZ_ORG_DEMOCRACY', 'column', 'GOAL_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '被考评部门id',
   'user', '', 'table', 'BIZ_ORG_DEMOCRACY', 'column', 'ORG_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '民主评议指标项得分',
   'user', '', 'table', 'BIZ_ORG_DEMOCRACY', 'column', 'SCORE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注，预留',
   'user', '', 'table', 'BIZ_ORG_DEMOCRACY', 'column', 'MEMO'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '考核责任单位id',
   'user', '', 'table', 'BIZ_ORG_DEMOCRACY', 'column', 'CHECK_ORG_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '考核年度',
   'user', '', 'table', 'BIZ_ORG_DEMOCRACY', 'column', 'YEAR'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '民主评议责任人类型id',
   'user', '', 'table', 'BIZ_ORG_DEMOCRACY', 'column', 'CHECKMAN_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '分值id，关联到 biz_democracy_score表',
   'user', '', 'table', 'BIZ_ORG_DEMOCRACY', 'column', 'SCORE_ID'
go

/*==============================================================*/
/* Table: BIZ_ORG_DEMOCRACY_SUM                                 */
/*==============================================================*/
CREATE TABLE BIZ_ORG_DEMOCRACY_SUM (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   ORG_ID               int                  null,
   SCORE_SUM            float                null,
   MEMO                 varchar(2048)        null,
   CHECK_ORG_ID         int                  null,
   YEAR                 int                  null,
   CHECKMAN_ID          int                  null,
   constraint PK_BIZ_ORG_DEMOCRACY_SUM primary key (ID)
)
go

DECLARE @CMTBIZ_ORG_DEMOCRACY_SUM VARCHAR(128)
SELECT @CMTBIZ_ORG_DEMOCRACY_SUM = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '评议责任人checkman对部门的评议总分表。在插入biz_org_democracy表后同时计算总分插入本表。（预留）',
   'user', @CMTBIZ_ORG_DEMOCRACY_SUM, 'table', 'BIZ_ORG_DEMOCRACY_SUM'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'BIZ_ORG_DEMOCRACY_SUM', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '被备考评部门id',
   'user', '', 'table', 'BIZ_ORG_DEMOCRACY_SUM', 'column', 'ORG_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '被考核部门，获得的总分。',
   'user', '', 'table', 'BIZ_ORG_DEMOCRACY_SUM', 'column', 'SCORE_SUM'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注，预留',
   'user', '', 'table', 'BIZ_ORG_DEMOCRACY_SUM', 'column', 'MEMO'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '考核责任单位id',
   'user', '', 'table', 'BIZ_ORG_DEMOCRACY_SUM', 'column', 'CHECK_ORG_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '考核年度',
   'user', '', 'table', 'BIZ_ORG_DEMOCRACY_SUM', 'column', 'YEAR'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '评议指标考核责任对象id',
   'user', '', 'table', 'BIZ_ORG_DEMOCRACY_SUM', 'column', 'CHECKMAN_ID'
go

/*==============================================================*/
/* Table: BIZ_ORG_GOAL_SETTING                                  */
/*==============================================================*/
CREATE TABLE BIZ_ORG_GOAL_SETTING (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   GOAL_TYPE            varchar(32)          null,
   NAME                 varchar(128)         null,
   ORG_ID               int                  null,
   GOAL_ID              int                  null,
   constraint PK_BIZ_ORG_GOAL_SETTING primary key (ID)
)
go

DECLARE @CMTBIZ_ORG_GOAL_SETTING VARCHAR(128)
SELECT @CMTBIZ_ORG_GOAL_SETTING = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '设置部门与考核指标关系，为多对多的关系表，设置之后方才可以考核',
   'user', @CMTBIZ_ORG_GOAL_SETTING, 'table', 'BIZ_ORG_GOAL_SETTING'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'BIZ_ORG_GOAL_SETTING', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '普通指标与加减分指标',
   'user', '', 'table', 'BIZ_ORG_GOAL_SETTING', 'column', 'GOAL_TYPE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '资源名称',
   'user', '', 'table', 'BIZ_ORG_GOAL_SETTING', 'column', 'NAME'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '父节点id（考虑到有树型资源）',
   'user', '', 'table', 'BIZ_ORG_GOAL_SETTING', 'column', 'ORG_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序',
   'user', '', 'table', 'BIZ_ORG_GOAL_SETTING', 'column', 'GOAL_ID'
go

/*==============================================================*/
/* Table: SYS_ORG                                               */
/*==============================================================*/
CREATE TABLE SYS_ORG (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   NAME                 varchar(256)         null,
   ORG_TYPE             varchar(32)          null,
   PARENT_ID            int                  null,
   ORG_LEVEL            int                  null,
   ORG_ORDER            int                  null,
   IS_LEAF              varchar(10)          null,
   FULL_ID_PATH         varchar(512)         null,
   FULL_NAME_PATH       varchar(1024)        null,
   MEMO                 varchar(1024)        null,
   constraint PK_SYS_ORG primary key (ID)
)
go

DECLARE @CMTSYS_ORG VARCHAR(128)
SELECT @CMTSYS_ORG = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织表',
   'user', @CMTSYS_ORG, 'table', 'SYS_ORG'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'SYS_ORG', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织类型。
   unit：垂直管理单位，dept：机关，town：乡镇，project：工业园区管委会和工程建设指挥部
   
   该枚举选项加入到资源表中',
   'user', '', 'table', 'SYS_ORG', 'column', 'ORG_TYPE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '父组织id',
   'user', '', 'table', 'SYS_ORG', 'column', 'PARENT_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '组织在组织树中的层次（第几层）',
   'user', '', 'table', 'SYS_ORG', 'column', 'ORG_LEVEL'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序号',
   'user', '', 'table', 'SYS_ORG', 'column', 'ORG_ORDER'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'y:是叶子节点，n：不是叶子节点',
   'user', '', 'table', 'SYS_ORG', 'column', 'IS_LEAF'
go

/*==============================================================*/
/* Table: SYS_PERMISSION                                        */
/*==============================================================*/
CREATE TABLE SYS_PERMISSION (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   RES_ID               varchar(32)          null,
   RES_NAME             varchar(128)         null,
   RES_TYPE             varchar(64)          null,
   RES_URL              varchar(256)         null,
   constraint PK_SYS_PERMISSION primary key (ID)
)
go

DECLARE @CMTSYS_PERMISSION VARCHAR(128)
SELECT @CMTSYS_PERMISSION = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '权限表',
   'user', @CMTSYS_PERMISSION, 'table', 'SYS_PERMISSION'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'SYS_PERMISSION', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '权限id（可以参考到资源表）',
   'user', '', 'table', 'SYS_PERMISSION', 'column', 'RES_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '权限名称',
   'user', '', 'table', 'SYS_PERMISSION', 'column', 'RES_NAME'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '权限类型',
   'user', '', 'table', 'SYS_PERMISSION', 'column', 'RES_TYPE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '访问url',
   'user', '', 'table', 'SYS_PERMISSION', 'column', 'RES_URL'
go

/*==============================================================*/
/* Table: SYS_RESOURCE                                          */
/*==============================================================*/
CREATE TABLE SYS_RESOURCE (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   TYPE                 varchar(32)          null,
   NAME                 varchar(128)         null,
   VALUE                varchar(2048)        null,
   PARENT_ID            int                  null,
   ORDERING             int                  null,
   VALUE1               varchar(2048)        null,
   VALUE2               varchar(2048)        null,
   VALUE3               varchar(2048)        null,
   VALUE4               varchar(2048)        null,
   VALUE5               varchar(2048)        null,
   constraint PK_SYS_RESOURCE primary key (ID)
)
go

DECLARE @CMTSYS_RESOURCE VARCHAR(128)
SELECT @CMTSYS_RESOURCE = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '资源表',
   'user', @CMTSYS_RESOURCE, 'table', 'SYS_RESOURCE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'SYS_RESOURCE', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '资源类型',
   'user', '', 'table', 'SYS_RESOURCE', 'column', 'TYPE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '资源名称',
   'user', '', 'table', 'SYS_RESOURCE', 'column', 'NAME'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '资源值',
   'user', '', 'table', 'SYS_RESOURCE', 'column', 'VALUE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '父节点id（考虑到有树型资源）',
   'user', '', 'table', 'SYS_RESOURCE', 'column', 'PARENT_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '排序',
   'user', '', 'table', 'SYS_RESOURCE', 'column', 'ORDERING'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '其它值',
   'user', '', 'table', 'SYS_RESOURCE', 'column', 'VALUE1'
go

/*==============================================================*/
/* Table: SYS_ROLE                                              */
/*==============================================================*/
CREATE TABLE SYS_ROLE (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   NAME                 varchar(256)         null,
   MEMO                 varchar(1024)        null,
   constraint PK_SYS_ROLE primary key (ID)
)
go

DECLARE @CMTSYS_ROLE VARCHAR(128)
SELECT @CMTSYS_ROLE = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '角色表',
   'user', @CMTSYS_ROLE, 'table', 'SYS_ROLE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'SYS_ROLE', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '角色名',
   'user', '', 'table', 'SYS_ROLE', 'column', 'NAME'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '备注 预留',
   'user', '', 'table', 'SYS_ROLE', 'column', 'MEMO'
go

/*==============================================================*/
/* Table: SYS_ROLE_PERMISSION                                   */
/*==============================================================*/
CREATE TABLE SYS_ROLE_PERMISSION (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   ROLE_ID              int                  null,
   PERMISSION_ID        int                  null,
   constraint PK_SYS_ROLE_PERMISSION primary key (ID)
)
go

DECLARE @CMTSYS_ROLE_PERMISSION VARCHAR(128)
SELECT @CMTSYS_ROLE_PERMISSION = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '角色权限分配表',
   'user', @CMTSYS_ROLE_PERMISSION, 'table', 'SYS_ROLE_PERMISSION'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'SYS_ROLE_PERMISSION', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '角色id',
   'user', '', 'table', 'SYS_ROLE_PERMISSION', 'column', 'ROLE_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '权限id',
   'user', '', 'table', 'SYS_ROLE_PERMISSION', 'column', 'PERMISSION_ID'
go

/*==============================================================*/
/* Table: SYS_USER                                              */
/*==============================================================*/
CREATE TABLE SYS_USER (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   LOGIN_ID             varchar(64)          null,
   PASSWORD             varchar(512)         null,
   ORG_ID               int                  null,
   USER_NAME            varchar(50)          null,
   EMAIL                varchar(100)         null,
   PHONE                varchar(50)          null,
   MOBILE               varchar(50)          null,
   ADDRESS              varchar(300)         null,
   ZIP_CODE             varchar(50)          null,
   SEX                  varchar(10)          null,
   BIRTHDAY             datetime             null,
   STATUS               varchar(30)          null default '1',
   DUTY                 varchar(30)          null,
   IS_MANAGER           char(1)              null,
   IS_DEMOCRACY         char(1)              null,
   DEMOCRACY_ID         int                  null,
   constraint PK_SYS_USER primary key (ID)
)
go

DECLARE @CMTSYS_USER VARCHAR(128)
SELECT @CMTSYS_USER = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '外经贸用户表',
   'user', @CMTSYS_USER, 'table', 'SYS_USER'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'SYS_USER', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '关联到表SYS_DEPARTMENT的id',
   'user', '', 'table', 'SYS_USER', 'column', 'ORG_ID'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户姓名',
   'user', '', 'table', 'SYS_USER', 'column', 'USER_NAME'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '邮政编码',
   'user', '', 'table', 'SYS_USER', 'column', 'ZIP_CODE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '性别 m：男 f：女',
   'user', '', 'table', 'SYS_USER', 'column', 'SEX'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '出生日期',
   'user', '', 'table', 'SYS_USER', 'column', 'BIRTHDAY'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   'alive：活动  stop：停止活动 ',
   'user', '', 'table', 'SYS_USER', 'column', 'STATUS'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '职务代码 关联到sys_resource中res_type=''duty''',
   'user', '', 'table', 'SYS_USER', 'column', 'DUTY'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否管理者',
   'user', '', 'table', 'SYS_USER', 'column', 'IS_MANAGER'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '是否民主评议员：y:是民主评议员，n：不是',
   'user', '', 'table', 'SYS_USER', 'column', 'IS_DEMOCRACY'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '民主评议员类型id',
   'user', '', 'table', 'SYS_USER', 'column', 'DEMOCRACY_ID'
go

/*==============================================================*/
/* Table: SYS_USER_ROLE                                         */
/*==============================================================*/
CREATE TABLE SYS_USER_ROLE (
   ID                   int                  identity(1,1),
   IS_DELETED           char(1)              null default 'n',
   CREATE_TIME          datetime             null,
   CREATOR              varchar(32)          null,
   MODIFY_TIME          datetime             null,
   MODIFIER             varchar(32)          null,
   ROLE_ID              int                  null,
   constraint PK_SYS_USER_ROLE primary key (ID)
)
go


DECLARE @CMTSYS_USER_ROLE VARCHAR(128)
SELECT @CMTSYS_USER_ROLE = USER_NAME()
EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '用户角色分配表',
   'user', @CMTSYS_USER_ROLE, 'table', 'SYS_USER_ROLE'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '删除标记 n 未删除 y 删除',
   'user', '', 'table', 'SYS_USER_ROLE', 'column', 'IS_DELETED'
go

EXECUTE SP_ADDEXTENDEDPROPERTY 'MS_Description', 
   '角色id',
   'user', '', 'table', 'SYS_USER_ROLE', 'column', 'ROLE_ID'
go

ALTER TABLE BIZ_GOAL_DETAIL
   ADD CONSTRAINT FK_BIZ_GOAL_REFERENCE_BIZ_GOAL FOREIGN KEY (CATEGORY_ID)
      REFERENCES BIZ_GOAL_CATEGORY (ID)
go

ALTER TABLE BIZ_ORG_CHECK
   ADD CONSTRAINT FK_BIZ_ORG__REFERENCE_BIZ_GOAL FOREIGN KEY (DETAIL_ID)
      REFERENCES BIZ_GOAL_DETAIL (ID)
go

ALTER TABLE BIZ_ORG_CHECK
   ADD CONSTRAINT FK_BIZ_ORG__REFERENCE_BIZ_GOAL FOREIGN KEY (DETAIL_ID)
      REFERENCES BIZ_GOAL_SELF (ID)
go

ALTER TABLE BIZ_ORG_DEMOCRACY
   ADD CONSTRAINT FK_BIZ_ORG__REFERENCE_BIZ_DEMO FOREIGN KEY (SCORE_ID)
      REFERENCES BIZ_DEMOCRACY_SCORE (ID)
go

ALTER TABLE BIZ_ORG_DEMOCRACY
   ADD CONSTRAINT FK_BIZ_ORG__REFERENCE_BIZ_DEMO FOREIGN KEY (GOAL_ID)
      REFERENCES BIZ_DEMOCRACY_GOAL (ID)
go

ALTER TABLE BIZ_ORG_DEMOCRACY
   ADD CONSTRAINT FK_BIZ_ORG__REFERENCE_BIZ_DEMO FOREIGN KEY (CHECKMAN_ID)
      REFERENCES BIZ_DEMOCRACY_CHECKMAN (ID)
go

ALTER TABLE BIZ_ORG_GOAL_SETTING
   ADD CONSTRAINT FK_BIZ_ORG__REFERENCE_SYS_ORG FOREIGN KEY (ORG_ID)
      REFERENCES SYS_ORG (ID)
go

ALTER TABLE BIZ_ORG_GOAL_SETTING
   ADD CONSTRAINT FK_BIZ_ORG__REFERENCE_BIZ_GOAL FOREIGN KEY (GOAL_ID)
      REFERENCES BIZ_GOAL_DETAIL (ID)
go

ALTER TABLE SYS_ROLE_PERMISSION
   ADD CONSTRAINT FK_SYS_ROLE_REFERENCE_SYS_PERM FOREIGN KEY (PERMISSION_ID)
      REFERENCES SYS_PERMISSION (ID)
go

ALTER TABLE SYS_ROLE_PERMISSION
   ADD CONSTRAINT FK_SYS_ROLE_REFERENCE_SYS_ROLE FOREIGN KEY (ROLE_ID)
      REFERENCES SYS_ROLE (ID)
go

ALTER TABLE SYS_USER
   ADD CONSTRAINT FK_SYS_USER_REFERENCE_SYS_ORG FOREIGN KEY (ORG_ID)
      REFERENCES SYS_ORG (ID)
go

ALTER TABLE SYS_USER_ROLE
   ADD CONSTRAINT FK_SYS_USER_REFERENCE_SYS_ROLE FOREIGN KEY (ROLE_ID)
      REFERENCES SYS_ROLE (ID)
go

ALTER TABLE SYS_USER_ROLE
   ADD CONSTRAINT FK_SYS_USER_REFERENCE_SYS_USER FOREIGN KEY (ID)
      REFERENCES SYS_USER (ID)
go

CREATE TABLE [BIZ_FILE] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[IS_DELETED] [char] (1) COLLATE Chinese_PRC_CI_AS NULL CONSTRAINT [DF__BIZ_FILE__IS_DELE__3B75D760] DEFAULT ('n'),
	[CREATE_TIME] [datetime] NULL ,
	[CREATOR] [varchar] (32) COLLATE Chinese_PRC_CI_AS NULL ,
	[MODIFY_TIME] [datetime] NULL ,
	[MODIFIER] [varchar] (32) COLLATE Chinese_PRC_CI_AS NULL ,
	[ORG_ID] [int] NULL ,
	[TYPE] [varchar] (32) COLLATE Chinese_PRC_CI_AS NULL ,
	[TITLE] [varchar] (1024) COLLATE Chinese_PRC_CI_AS NULL ,
	[STATUS] [varchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
	[FILE_PATH] [varchar] (1024) COLLATE Chinese_PRC_CI_AS NULL ,
	[MEMO] [varchar] (1024) COLLATE Chinese_PRC_CI_AS NULL ,
	CONSTRAINT [PK_BIZ_FILE] PRIMARY KEY  CLUSTERED 
	(
		[ID]
	)  ON [PRIMARY] 
) ON [PRIMARY]
GO
CREATE TABLE [BIZ_ORG_DEMOCRACY_SETTING](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[IS_DELETED] [char](1) NULL,
	[CREATE_TIME] [datetime] NULL,
	[CREATOR] [varchar](32) NULL,
	[MODIFY_TIME] [datetime] NULL,
	[MODIFIER] [varchar](32) NULL,
	[ORG_TYPE] [varchar](32) NULL,
	[DEMOCRACY_GOAL_ID] [int] NULL
) ON [PRIMARY]
GO